package virtPresenter.model
{
	import flash.display.Sprite;
	
	import mx.core.UIComponent;
	
	/**
	 * Manages and represents the referenceLiness for the tsf Slider
	 * 
	 * @author Sebastian Pospiech
	 */
	public class AnimationReferenceLines
	{

		private static var referenceLines: Sprite = new Sprite();
		private static var instance:AnimationReferenceLines;
		
		public function AnimationReferenceLines(parentObject:UIComponent){
			parentObject.addChild(referenceLines);
			referenceLines.useHandCursor = false;
			instance = this;
		}
		
		public static function getInstance():AnimationReferenceLines{
			return instance;
		}
		
		/**
		 * sets the x coordinate of the sprite, the reference line is painted in.
		 * 
		 * @param x:int
		 */
		public function setX(x:int):void{
			referenceLines.x = x;
		}
		
		/**
		 * sets the y coordinate of the sprite, the reference line is painted in.
		 * 
		 * @param y:int
		 */
		public function setY(y:int):void{
			referenceLines.y = y;
		}
		
		/**
		 * draws the referenceLiness with the given line values
		 * 
		 * @param lv: Array of line values
		 */
		public function drawReferenceLiness(lv:Array, previewPosition:int, isFirst:Boolean, isLast:Boolean):void{
			referenceLines.graphics.clear();
			referenceLines.graphics.beginFill(0x666666);   
			referenceLines.graphics.lineStyle(2,0xaaaaff);
			//draw inner left line
			referenceLines.graphics.moveTo(-70-(previewPosition),AS_Constants.SCRUBBER_HEIGHT+40);
			referenceLines.graphics.lineTo(lv[2]-referenceLines.x,AS_Constants.SCRUBBER_HEIGHT);
			//draw it vertically up
			referenceLines.graphics.moveTo(lv[2]-referenceLines.x,0);
			referenceLines.graphics.lineTo(lv[2]-referenceLines.x,AS_Constants.SCRUBBER_HEIGHT);
			//draw inner right line
			referenceLines.graphics.moveTo(70-(previewPosition),AS_Constants.SCRUBBER_HEIGHT+40);
			referenceLines.graphics.lineTo(lv[3]-referenceLines.x,AS_Constants.SCRUBBER_HEIGHT);
			referenceLines.graphics.moveTo(lv[3]-referenceLines.x,0);
			referenceLines.graphics.lineTo(lv[3]-referenceLines.x,AS_Constants.SCRUBBER_HEIGHT);
			//draw outer left line
			if (!isFirst && !FisheyeWindow.getInstance().getPreviewMode()){
				trace("drawLine");
				referenceLines.graphics.moveTo(-200-(previewPosition),AS_Constants.SCRUBBER_HEIGHT+45);
				referenceLines.graphics.lineTo(lv[0]-referenceLines.x,AS_Constants.SCRUBBER_HEIGHT);
				referenceLines.graphics.moveTo(lv[0]-referenceLines.x,0);
				referenceLines.graphics.lineTo(lv[0]-referenceLines.x,AS_Constants.SCRUBBER_HEIGHT);
			}
			//draw outer right line
			if(!isLast && !FisheyeWindow.getInstance().getPreviewMode()){
				trace("drawLine");
				referenceLines.graphics.moveTo(200-(previewPosition),AS_Constants.SCRUBBER_HEIGHT+45);
				referenceLines.graphics.lineTo(lv[1]-referenceLines.x,AS_Constants.SCRUBBER_HEIGHT);
				referenceLines.graphics.moveTo(lv[1]-referenceLines.x,0);
				referenceLines.graphics.lineTo(lv[1]-referenceLines.x,AS_Constants.SCRUBBER_HEIGHT);
			}
			referenceLines.graphics.endFill();
		}
	}
}